package com.shop.admin.service.user;

import com.shop.domain.user.UserIntegralBill;
import com.shop.web.response.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

@Service
@Slf4j
@Transactional
public class UserIntegtralBillService {

    @Autowired
    private UserIntegralBillDao userIntegralBillDao;


    /**
     * 增加用户积分记录流水
     * @param userId  用户ID
     * @param linkId  关联ID（拼团订单ID）
     * @param initIntegral  原始积分
     * @param integral  积分
     * @param refreshIntegral  更新后积分
     * @param tableName 业务类型
     * @param pm 流水类型 0收入 1支出
     * @param mark 备注
     * @return
     */
    public BaseResponse addUserIntegralBill(Long userId, Long linkId, BigDecimal initIntegral, BigDecimal integral,BigDecimal refreshIntegral, String tableName,
                                     int pm, String mark) {

        UserIntegralBill userIntegralBill = new UserIntegralBill();
        userIntegralBill.setUid(userId);
        userIntegralBill.setLinkId(linkId);
        userIntegralBill.setInitIntegral(initIntegral);
        userIntegralBill.setIntegral(integral);
        userIntegralBill.setRefreshIntegral(refreshIntegral);
        userIntegralBill.setTableName(tableName);
        userIntegralBill.setPm(pm);
        userIntegralBill.setMark(mark);
        userIntegralBillDao.save(userIntegralBill);

        return new BaseResponse();
    }




}
